package chat;

import java.net.Socket;
import java.net.ServerSocket;
import java.io.*;
import java.util.Vector;
public class Server
{
	ServerSocket server;
	SocketManager manager=new SocketManager();
	public Server()
	{
		
	}
	void startServer()
	{
		try
		{
			server=new ServerSocket(5000);
			System.out.println("建立端口");
			
			System.out.println("等待客户端连接...");
			while(true)
			{
				
				Socket socket=server.accept();
				System.out.println("客户端已连接");
				new ChatThread(socket).start();
				manager.add(socket);
				manager.sendClientNum();
			}
		}
		catch(Exception e)
		{
			System.err.println("发生异常:"+e);
			e.printStackTrace();
		}
	}
	public  void  openServer(){
		Server server=new Server();
		server.startServer();
	}
}
